home *** CD-ROM | disk | FTP | other *** search
- Path: crchh327.rich.bnr.ca!jobell
- From: jobell@bnr.ca (Bret Bieghler)
- Newsgroups: comp.lang.c++
- Subject: Re: Is there a standard for * and & placement style?
- Date: 20 Feb 1996 13:20:59 GMT
- Organization: Bell-Northern Research Ltd.
- Message-ID: <4gchrr$7r9@crchh327.rich.bnr.ca>
- References: <3128BD31.4AF8@wildfire.com>
- NNTP-Posting-Host: crchh524.rich.bnr.ca
-
- In article <3128BD31.4AF8@wildfire.com>,
- Stonewall Ballard <stoney@wildfire.com> wrote:
- >I'm trying to find out whether there is a "standard" for the
- >placement of * and &. A survey of C++ texts shows that most use
- >
- >Form 1
- > int& foo;
- > int* foo;
- >
- >while some use
- >
- >Form 2
- > int& foo;
- > int *foo;
- >
- >and nobody uses (although I've seen this a lot in code)
- >
- >Form 3
- > int &foo;
- > int *foo;
-
- Most C textbooks that I've seen use the following:
-
- int *foo;
-
- and give the reason that it reminds you that the pointer
- operator only associates itself with one variable, thus
-
- int *foo, foo2, foo3
-
- declares an int pointer (foo), and two ints.
-
- Thus,
-
- int* foo, foo2, foo3;
-
- is equivalent.
-
- However, since it is "bad practice" to delcare more
- than one variable on a line, most C++ books use
-
- int* foo
-
- to show you that you are declaring an int pointer.
-
- or
-
- int& foo
-
- int reference.
-
- JB
-
- >Thanks very much!
- >
- > - Stoney
-
- your welcome.
- >
- >
- >----------------------------------------------------------------
- >-------
- >Stonewall Ballard "I have one grunch but the eggplant over
- >there"
- >stoney@wildfire.com (work) Wildfire
- >Communications, Inc.
- >stoney@beeblebrox.com (home)
- >http://www.tiac.net/users/stoney/
-
-
- --
- Joseph A. Bell (NOT Bret Bieghler) jobell@bnr.ca
- Northern Telecom / Bell-Northern Research
- "What? Evacuate now, in our moment of triumph? Surely you overestimate their chances."
-